﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Xml.Linq;
using TodoList.ViewModel;
using TodoList.Mode;
using TodoList.Common;
using Microsoft.Win32;

namespace TodoList.Command
{
    class LoadCommand : ICommand
    {
        #region ICommand Members
        TodoVM vm;
        public bool CanExecute(object parameter)
        {
            vm = parameter as TodoVM;
            if (vm == null) return true;
            if (vm.FileName.Length == 0) return false;
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            vm = parameter as TodoVM;
            List<Todo> todoList = Utils.GetTodoList(vm.FileName);
            vm.TodoList = todoList;
        }
        #endregion
    }
}
